package com.ruoyi.process.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.process.domain.Workflowcate;
import com.ruoyi.process.service.IWorkflowcateService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 流程分类Controller
 * 
 * @author wuenguo
 * @date 2025-07-05
 */
@RestController
@RequestMapping("/process/workflowcate")
public class WorkflowcateController extends BaseController
{
    @Autowired
    private IWorkflowcateService workflowcateService;

    /**
     * 查询流程分类列表
     */
    @PreAuthorize("@ss.hasPermi('process:workflowcate:list')")
    @GetMapping("/list")
    public AjaxResult list(Workflowcate workflowcate)
    {
        List<Workflowcate> list = workflowcateService.selectWorkflowcateList(workflowcate);
        return success(list);
    }

    /**
     * 导出流程分类列表
     */
    @PreAuthorize("@ss.hasPermi('process:workflowcate:export')")
    @Log(title = "流程分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Workflowcate workflowcate)
    {
        List<Workflowcate> list = workflowcateService.selectWorkflowcateList(workflowcate);
        ExcelUtil<Workflowcate> util = new ExcelUtil<Workflowcate>(Workflowcate.class);
        util.exportExcel(response, list, "流程分类数据");
    }

    /**
     * 获取流程分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('process:workflowcate:query')")
    @GetMapping(value = "/{pcid}")
    public AjaxResult getInfo(@PathVariable("pcid") Long pcid)
    {
        return success(workflowcateService.selectWorkflowcateByPcid(pcid));
    }

    /**
     * 新增流程分类
     */
    @PreAuthorize("@ss.hasPermi('process:workflowcate:add')")
    @Log(title = "流程分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Workflowcate workflowcate)
    {
        return toAjax(workflowcateService.insertWorkflowcate(workflowcate));
    }

    /**
     * 修改流程分类
     */
    @PreAuthorize("@ss.hasPermi('process:workflowcate:edit')")
    @Log(title = "流程分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Workflowcate workflowcate)
    {
        return toAjax(workflowcateService.updateWorkflowcate(workflowcate));
    }

    /**
     * 删除流程分类
     */
    @PreAuthorize("@ss.hasPermi('process:workflowcate:remove')")
    @Log(title = "流程分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pcids}")
    public AjaxResult remove(@PathVariable Long[] pcids)
    {
        return toAjax(workflowcateService.deleteWorkflowcateByPcids(pcids));
    }
}
